# 二分查找最小值


class Solution:

    def findMin(self, nums):

        if len(nums) == 1 or nums[0] < nums[-1]:
            return nums[0]
        
        l, r = 0, len(nums) - 1
        while l < r:
            mid = l + (r - l) // 2

            if nums[mid] < nums[r]:
                r = mid
            else:
                l = mid + 1
        
        return nums[l]



if __name__ == "__main__":
    a = [4,5,6,7,0,1,2]
    sol = Solution()
    res = sol.findMin(a)
    print(res)


